Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle NotImplementedError exception while calling get_eeprom_path API #399

Closed

Conversation

mihirpat1
Copy link
Contributor

Description

For platforms which do not implement get_eeprom_path API, NotImplementedError will be returned.
We need to handle such case and allow FW download to proceed since the corresponding platform may not support Optoe driver and would have get_eeprom_path not implemented.

https://github.com/sonic-net/sonic-platform-common/blob/master/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py#L169

https://github.com/sonic-net/sonic-platform-common/blob/master/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py#L148

Motivation and Context

Error seen while initiating FW download when get_eeprom_path is not defined

root@dut:/firmware# sfputil firmware download Ethernet144 fw.bin
CDB: Starting firmware download
Traceback (most recent call last):
  File "/usr/local/bin/sfputil", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/sfputil/main.py", line 1508, in download
    status = download_firmware(port_name, filepath)
  File "/usr/local/lib/python3.9/dist-packages/sfputil/main.py", line 1365, in download_firmware
    sfp.set_optoe_write_max(SMBUS_BLOCK_WRITE_SIZE)
  File "/usr/local/lib/python3.9/dist-packages/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py", line 170, in set_optoe_write_max
    sys_path = self.get_eeprom_path()
  File "/usr/local/lib/python3.9/dist-packages/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py", line 149, in get_eeprom_path
    raise NotImplementedError
NotImplementedError
root@dut:/firmware#

With the current change, "sfputil firmware download <fw_path>" CLI will not exit due to exception and will be allowed to proceed further when get_eeprom_path is not implemented

How Has This Been Tested?

The "sfputil firmware download <fw_path>" CLI was verified successfully in the following scenarios

  1. When get_eeprom_path API is implemented
  2. When get_eeprom_path API is not implemented

Additional Information (Optional)

@mihirpat1 mihirpat1 marked this pull request as ready for review September 17, 2023 20:27
@mihirpat1 mihirpat1 requested a review from prgeor September 17, 2023 20:28
@mihirpat1
Copy link
Contributor Author

Opened the below PR to fix this
sonic-net/sonic-utilities#2985

@mihirpat1 mihirpat1 closed this Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant